package com.hcqc.demo.controller;

import com.hcqc.demo.pojo.Form1;
import com.hcqc.demo.server.Form1Server;
import com.hcqc.demo.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.List;

@RestController
@RequestMapping("/Form1")
public class Form1Controller {
    @Autowired
    Form1Server form1Server;

    @RequestMapping("/SelectALL")
    public Result SelectALL(HttpServletRequest request, Form1 search, Integer pageIndex, Integer pageSize){
//        System.out.println(search);
        HttpSession session=request.getSession();
        String user_name = (String) session.getAttribute("USER_NAME");
//        List<Form1> data = form1Server.SelectALL(user_name,search);
        Result result=form1Server.selectAllAndPage(user_name,search,pageIndex+1,pageSize);
//        System.out.println(data);
        return result;
    }

    @RequestMapping("/delete")
    public void delete(String IDs){
        form1Server.delete(IDs);
    }

    @RequestMapping("/addOne")
    public void addOne(Form1 form1){
        form1Server.addOne(form1);
    }
}
